﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NEXEntidad;

public partial class ListarEventos : System.Web.UI.Page
{

    #region Eventos de Pagina
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (User.Identity.IsAuthenticated && ((Usuario)Session["Usuario"]).EsAdministrador)
            {
                gviewEventos.DataSource = EventoCultural.Listar(true, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)));
                gviewEventos.DataBind();
            }
            else
            {
                Response.Redirect("Default2.aspx");
            }
        }
    }
    protected void gviewEventos_RowEditing(object sender, GridViewEditEventArgs e)
    {
        try
        {
            int idEvento;
            idEvento = Convert.ToInt32(gviewEventos.Rows[e.NewEditIndex].Cells[0].Text);
            Response.Redirect("CargaEventos.aspx?idEvento=" + idEvento.ToString());
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void btnAgregar_Click(object sender, EventArgs e)
    {
        Response.Redirect("CargaEventos.aspx");
    }

    #endregion
    }
